
$(document).ready(function () {
	$('.banner .owl-demo').owlCarousel({
		items: 1,
		singleItem: true,
		autoPlay: true,
		navigation: true,
		navigationText: ["", ""],
		lazyLoad: true,
		scrollPerPage: false,
		slideSpeed: 800,
	});

	$(window).scroll(function () {
		if (jQuery(this).scrollTop() > 1) {
			$(".header").addClass("header_scroll");
		} else {
			$(".header").removeClass("header_scroll");
		}
	});
	$(".aside ul li.consulting").click(function () {
		$(".aside ul li.consulting").addClass("active");
		$(".consulting_box").css("right", "40px");
	});
	$(".consulting_box .close").click(function () {
		$(".aside ul li.consulting").removeClass("active");
		$(".consulting_box").css("right", "-250px");
	});
	$(".header .mobileMenuBtn").click(function () {
		$(".header .mobileMenuBtn").toggleClass("active");
		$(".header .header_menu").toggleClass("active");
		$(".header .mobileMenuBtn_shad").toggleClass("active");
	});
	$(".header .mobileMenuBtn_shad").click(function () {
		$(".header .mobileMenuBtn").toggleClass("active");
		$(".header .header_menu").toggleClass("active");
		$(".header .mobileMenuBtn_shad").toggleClass("active");
	});
	var w_width = $(window).width();
	if (w_width < 767) {
		$(".technical_support_type .title").click(function () {
			$(".technical_support_type ul").slideToggle();
			$(".technical_support_type .title span").toggleClass("active");
		});
	} else {

	}

	if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
		var wow = new WOW({
			boxClass: 'wow',
			animateClass: 'animated',
			offset: 150,
			mobile: true,
			live: true
		});

		wow.init();
	};


	var win_width = $(window).width();
	if (win_width > 1024) {
		// 202208071652 sry 注释引入js文件报错
		// $.getScript("/js/cpgwjs/line1.js");
		// $.getScript("/js/cpgwjs/line2.js");
	} else { }

	jQuery(window).resize(function () {
		var win_width = $(window).width();
		if (win_width > 1024) {
			// 202208071652 sry 注释引入js文件报错
			// $.getScript("/js/cpgwjs/line1.js");
			// $.getScript("/js/cpgwjs/line2.js");
		} else { }
	});



	// 202208071651 sry 注释滚动事件报错
	// $(window).scroll(function () {

	// 	if (jQuery(this).scrollTop() < 100) {

	// 		toTop.css("bottom", "-100px");

	// 	} else {

	// 		toTop.css("z-index", 10000);

	// 		toTop.css("bottom", "60px");

	// 	}

	// });

	var close = $("#close");
	close.on("click", function () {
		$("#show").animate({
			width: '40px'
		}, 100);
		$('.aside,#toTop,#close').animate({
			width: 0
		}, 100);
	})

	var show = $("#show");
	show.on("click", function () {
		$("#show").animate({
			width: '0px'
		}, 100);
		$('.aside,#toTop,#close').animate({
			width: "40px"
		}, 100);
	})
});

// 202208081349 sry 禁止鼠标右键 
document.oncontextmenu = new Function('event.returnValue=false;');
document.onselectstart = new Function('event.returnValue=false;');

$(document).on('click', '#form .form-save', function() {
	let fullName = $('#form input[name="fullName"]')
	let phone = $('#form input[name="phone"]')
	let demand = $('#form select[name="demand"]')
	if (fullName.val() == '') {
		alert('请输入您的姓名')
		return false
	}
	if (phone.val() == '') {
		alert('请输入您的电话')
		return false
	}
	if (!/^1[3456789]\d{9}$/.test(phone.val())) {
		alert('您的电话有误')
		return false
	}
	if (demand.val() == '') {
		alert('请选择您的需求')
		return false
	}
	$('#form .form-save').attr('disabled', true)
	$.ajax({
		url: 'http://apiys.021yssy.com/ys/api/v1/api/messageBoard/addMessageBoard',
		type: 'post',
		data: {
			fullName: fullName.val(),
			phone: phone.val(),
			demand: demand.val(),
			ip: $('input[name="ip"]').val()
		},
		success: function(res) {
			if (res.code != 200) {
				alert(res.msg)
				$('#form .form-save').attr('disabled', false)
				return false
			}
			fullName.val('')
			phone.val('')
			demand.val('')
			alert(res.msg)
			$('#form .form-save').attr('disabled', false)
		},
		error: function(err) {
			// console.log(err)
			$('#form .form-save').attr('disabled', false)
		}
	})
})
$(document).on('click', '#backtop', function() {
	$('html').animate({
		scrollTop: 0
	})
})